﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Library;
namespace QuanLyThi
{
    public partial class FrmBangDiemHocVien : Form
    {
        public static string mConnect = FrmMain.mConnect;
        private string msql = "";
        public DGC_Library mLibrary = new DGC_Library(mConnect);

        public FrmBangDiemHocVien()
        {
            InitializeComponent();
            this.Load();           
        }
        private void button6_Click(object sender, EventArgs e)
        {
            this.Close();
        }
        private void Load()
        {
            msql = "Select * from TB_hssv order by ms_hssv";
            DataTable dt = mLibrary.GetDataTable(msql, "table");
            CMSHOCVIEN.DataSource = dt;
            CMSHOCVIEN.DisplayMember = "ms_Hssv";
            CMSHOCVIEN.ValueMember = "hovaten";
            textBox1.Text = CMSHOCVIEN.SelectedValue.ToString();
        }

        private void button6_Click_1(object sender, EventArgs e)
        {
            this.Close();
        }

        private void CMSHOCVIEN_SelectionChangeCommitted(object sender, EventArgs e)
        {
            textBox1.Text = CMSHOCVIEN.SelectedValue.ToString();
            //
            msql = "Select a.CT_daotao,c.Khoadaotao,d.Tenlop,j.ms_hssv,j.hovaten, f.Mondaotao,i.diemthi, Case i.ketqua When 1 " +
                  "  then N'Đạt' When 0 then N'Hỏng' Else '' End as ketqua ,i.lanthi,i.Ngaythi,k.Tenloaithi from tb_CTdaotao a " +
                  "  inner join tb_cauhinhCTdaotao b on a.ms_daotao=b.ms_daotao inner join tb_khoadaotao c " +
                  "  on b.ms_khoadaotao=c.ms_khoadaotao inner join tb_lopdaotao d on c.ms_khoadaotao=d.ms_khoadaotao " +
                  "  and d.ms_daotao=a.ms_daotao inner join tb_cauhinhlop e on d.ms_lop=e.ms_lop inner join tb_mondaotao f " +
                  "  on e.ms_mondaotao=f.ms_mondaotao inner join tb_hssvlop g on d.ms_lop=g.ms_lop inner join tb_hssvthi i " +
                  "  on g.ms_hssv=i.ms_hssv and e.ms_mondaotao=i.ms_mondaotao and g.ms_lop=i.ms_lop inner join tb_hssv j " +
                  "  on g.ms_hssv=j.ms_hssv inner join tb_loaihinhthi k on i.ms_loaithi=k.ms_loaithi Where  g.ms_hssv='"+CMSHOCVIEN.Text.ToString()+"' " +
                  "  order by a.CT_daotao,c.Khoadaotao,d.Tenlop,f.Mondaotao,Tenloaithi,i.lanthi,i.ketqua";
            dataGridView1.AutoGenerateColumns = false;
            dataGridView1.DataSource = mLibrary.GetDataTable(msql, "a");
        }    
   
    
       
      

      

         
     
    }
}
